import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import AutoImport from 'unplugin-auto-import/vite'

export default defineConfig({
  plugins: [
    uni(),
    AutoImport({
      imports: ['vue', 'uni-app'],
      // 显式指定插件名称，避免类型冲突
      dts: true, // 可选：生成自动导入的类型声明文件
    }),
  ],
  build: {
    rollupOptions: {
      output: {
        // 忽略空 chunk 警告
        chunkFileNames: (chunkInfo) => {
          if (chunkInfo.name.includes('digit')) {
            return 'assets/[name]-[hash].js';
          }
          return 'assets/[name]-[hash].js';
        },
      },
    },
  },
})